function updIndexBannerDialog(
    {
        bannerId, callback = Function()
    }
) {
    if (!bannerId) {
        return $.toast("bannerId不能为空");
    }

    getIndexBannerDetails({bannerId}, ({Code, Message, Result}) => {
        if (Code !== 10000) {
            return $.toast(Message);
        }

        const {title, imgUrl, targetUrl, sortIndex} = Result;

        const $form = $(`
            <form class="mask-account">
                <input type="hidden" name="bannerId" value="${bannerId}">
                <div style="margin: 0">
                    <span class="mask-account-tit"><sub style="color: red;">*</sub>标题</span>
                    <span class="input-select">
                        <input type="text" name="title" value="${title || ''}" placeholder="请输入标题" />
                    </span>
                </div>
                <div>
                    <span class="mask-account-tit"><sub style="color: red;">*</sub>广告图片</span>
                    <div class="input-select" style="border: 0;padding: 0">
                        <input type="hidden" name="imgUrl">
                    </div>
                </div>
                
                <div>
                    <span class="mask-account-tit">广告地址</span>
                    <span class="input-select"><input type="text" name="targetUrl" value="${targetUrl || ""}" placeholder="请输入广告地址" /></span>
                </div>
                
                <div>
                    <span class="mask-account-tit">排序</span>
                    <span class="input-select"><input type="number" value="${sortIndex || 10}" name="sortIndex" placeholder="请输入排序,小的排前面" /></span>
                </div>
      
            </form>
        `)

        const $imgUrlInput = $form.find('input[name="imgUrl"]');

        $imgUrlInput.after(getUploadImgWidget({
            maxCount: 1,
            maxSize: 1024 * 5,
            imageUrls: imgUrl ? imgUrl.split(",") : [],
            callback(urlList) {
                $imgUrlInput.val(urlList.join(","))
            }
        }));

        const $dialogWidget = $.dialog($form, {
            title: "编辑首页广告",
            width: "600px",
            ok: () => {
                const data = $.getFormData($form);

                updIndexBanner(data, res => {
                    const {Code, Message} = res;
                    if (Code !== 10000) {
                        return $.toast(Message);
                    }

                    $dialogWidget.remove();
                    $.toast("编辑成功");
                    callback();
                })

                return false;
            }
        })
    });


    function updIndexBanner(param, callback = Function()) {
        return $.sApi({
            data: param,
            url: "/api/IndexBanner/updIndexBanner"
        }, callback)
    }

    function getIndexBannerDetails(param, callback = Function()) {
        return $.sApi({
            data: param,
            url: "/api/IndexBanner/getIndexBannerDetails"
        }, callback)
    }
}